#include<stdio.h>
int main()
{
	int year1[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int year2[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int year=0;
	int month=0;
	int day=0;
	scanf("%d%d%d",&year,&month,&day);
	int sum=0;
	if(year%400==0||(year%4==0&&year%100!=0))
	{
		for(int i=1;i<month;i++)
		{
			sum+=year1[i];
		}
		sum+=day;
	}
	else
	{
		for(int i=1;i<month;i++)
		{
			sum+=year2[i];
		}
		sum+=day;
	}
	printf("%d",sum);
	return 0;	
}
